import { useEffect, useState } from 'react';
import { AppState, StatusBar } from 'react-native';
const useAppStateChange  = () => {
    const [appState, setAppState] = useState(AppState.currentState);

    useEffect(() => {
      StatusBar.setBarStyle("light-content");
      StatusBar.setBackgroundColor("#000000");
      const handleAppStateChange = (nextAppState: any) => {
        if (appState.match(/inactive|background/) && nextAppState === "active") {
          StatusBar.setBarStyle("light-content");
          StatusBar.setBackgroundColor("#000000");
        }
        setAppState(nextAppState);
      };
  
      const subscription = AppState.addEventListener(
        "change",
        handleAppStateChange
      );
  
      return () => {
        subscription.remove();
      };
    }, [appState]);
  
    return appState;
  };
  
  export default useAppStateChange ;